<template>
  <view class="merchantdetail">
    <view class="top">
      <image :src="img1" />
      <view class="top-content">
        <view class="top-content1">
          <view class="top-content1-title">{{ datas.name }}</view>
          <view class="top-content1-text">{{ datas.introduction }}</view>
        </view>
        <view class="top-content-bottom">
          <view class="bottom-content2">
            <view class="bottom-content2-title"
              >{{datas.address}}</view
            >
            <view class="bottom-content2-text"
              >{{datas.location}}</view
            >
          </view>
          <image :src="phoneicon" @tap="calling" class="phoneicon"></image>
        </view>
      </view>
    </view>

    <view class="bottom">
      <view class="title">店内环境</view>
      <!-- <view>
        <view class="imagelist">
          <scroll-view
            class="scroll-view_H"
            scroll-x="true"
            bindscroll="scroll"
            style="width: 720rpx"
          >
            <image
              v-for="(item, index) in datas.gallery"
              :key="index"
              class="image"
              :src="image(item)"
              :style="index == 0 ? 'margin-left:40rpx' : 'margin-left:12rpx'"
            ></image>
            <view id="demo1" class="scroll-view-item_H demo-text-1">111</view>
            <view id="demo2" class="scroll-view-item_H demo-text-2">222</view>
            <view id="demo3" class="scroll-view-item_H demo-text-3">333</view> 
          </scroll-view>
        </view>-->
        <view class="bottom-text" style="color: #666"
          >所属商圈：{{ datas.shopping_district_id.name }}</view
        >
        <view class="bottom-text">入驻时间：{{ gettime }}</view>
        <view class="bottom-text">商户电话：{{datas.contact}}</view>
      </view>
    </view>
  </view>
</template>

<script>
import "./index.scss";
import Taro, { Component, getCurrentInstance } from "@tarojs/taro";
import img1 from "../../../assets/image/build1.png";
import phoneicon from "../../../assets/icon/phone.png";
import request, { getImage } from "../../../utils/request";
import formatTime from "../../../utils/formatTime";
// bottom
// import Taro from "@tarojs/taro";search
export default {
  components: {},
  data() {
    return {
      detailId: "",
      datas: { shopping_district_id: {} },
      list: [{ image: img1 }, { image: img1 }, { image: img1 }],
      phoneicon: phoneicon,
      img1: "",
    };
  },

  computed: {
    // 计算属性的 getter
    gettime: function () {
      // `this` 指向 vm 实例
      const time = this.datas.join_dtt;
      // var currenttime= res.data.timeStamp;formatTime(time, "yyyy年MM月")

      return formatTime(time, "yyyy年mm月");
    },
  },

  created() {
    this.detailId = getCurrentInstance().router.params.id;
    this.getBusinessesDetail();
  },

  methods: {
    getBusinessesDetail() {
      request("get", `/api/rest/businesses/${this.detailId}.htm`).then(
        (res) => {
          console.log(res, "getBusinessesDetail");
          this.datas = res;
          console.log(res.face_image_id);
          this.img1 = getImage(res.face_image_id);
        }
      );
    },

    image(id) {
      return getImage(id);
    },

    calling() {
      wx.makePhoneCall({
        phoneNumber: this.datas.contact,
        success:  ()=> {
          console.log("拨打电话成功", this.datas.contact);
        },
        fail: ()=> {
          console.log("拨打电话失败", this.datas.contact);
        },
      });
    },
    
  
  },
};
</script>
